// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2024 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.13.1
package sys

import (
	"context"
	"hotgo/api/admin/stockblockdetail"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	StockBlockDetail = cStockBlockDetail{}
)

type cStockBlockDetail struct{}

// List 查看板块详情列表
func (c *cStockBlockDetail) List(ctx context.Context, req *stockblockdetail.ListReq) (res *stockblockdetail.ListRes, err error) {
	list, totalCount, err := service.SysStockBlockDetail().List(ctx, &req.StockBlockDetailListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.StockBlockDetailListModel{}
	}

	res = new(stockblockdetail.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出板块详情列表
func (c *cStockBlockDetail) Export(ctx context.Context, req *stockblockdetail.ExportReq) (res *stockblockdetail.ExportRes, err error) {
	err = service.SysStockBlockDetail().Export(ctx, &req.StockBlockDetailListInp)
	return
}

// Edit 更新板块详情
func (c *cStockBlockDetail) Edit(ctx context.Context, req *stockblockdetail.EditReq) (res *stockblockdetail.EditRes, err error) {
	err = service.SysStockBlockDetail().Edit(ctx, &req.StockBlockDetailEditInp)
	return
}

// View 获取指定板块详情信息
func (c *cStockBlockDetail) View(ctx context.Context, req *stockblockdetail.ViewReq) (res *stockblockdetail.ViewRes, err error) {
	data, err := service.SysStockBlockDetail().View(ctx, &req.StockBlockDetailViewInp)
	if err != nil {
		return
	}

	res = new(stockblockdetail.ViewRes)
	res.StockBlockDetailViewModel = data
	return
}

// Delete 删除板块详情
func (c *cStockBlockDetail) Delete(ctx context.Context, req *stockblockdetail.DeleteReq) (res *stockblockdetail.DeleteRes, err error) {
	err = service.SysStockBlockDetail().Delete(ctx, &req.StockBlockDetailDeleteInp)
	return
}
